package top.zhangjianyong.tools.utils;

import top.zhangjianyong.tools.entity.Vegetable;

import java.util.*;

/**
 * @author ： zhangjianyong
 * @date ： 2022/11/23 2:02 PM
 */
public class CanteenVegetableHolder {

    private static List<Vegetable> list = new ArrayList<>();

    public static void init() {
        list = new ArrayList<>();
    }

    public synchronized static void add(List<Vegetable> vegetables) {
        list.addAll(vegetables);
    }

    public static List<Vegetable> getList() {
        Map<String, Vegetable> map = new HashMap<>();
        for (Vegetable v : list) {
            map.put(v.getNo(), v);
        }
        return new ArrayList<>(map.values());
    }
}
